/**
 * 
 */
var url = "/commodities/search";
	$(document).ready(function(){
		$("#all").click(function(){
			$("#all").addClass("buttonColor");
			$("#drink").removeClass("buttonColor");
			$("#food").removeClass("buttonColor");
			$.post(
					url,
					{claname:'all'},
					function(data){
						GreateCommoditiesList(data);
					}
			);
			
			
		});
		$("#drink").click(function(){
			$("#drink").addClass("buttonColor");
			$("#all").removeClass("buttonColor");
			$("#food").removeClass("buttonColor");	
			
			$.post(
					url,
					{claname:'drink'},
					function(data){
						GreateCommoditiesList(data);
					}
			);
			
				});
		$("#food").click(function(){
			$("#food").addClass("buttonColor");
			$("#drink").removeClass("buttonColor");
			$("#all").removeClass("buttonColor");
			
			$.post(
					url,
					{claname:'food'},
					function(data){
						GreateCommoditiesList(data);
					}
			);
			
		});
		
	
		
	});
	
	function GreateCommoditiesList(datas){
		$(".hot-course-img-con").html("");
		for(var i=0;i<datas.length;i++ ){
			
			if(datas[i].laNum > 0){
				$(".hot-course-img-con").append("<a href='/commodities/detail?latid="+datas[i].id+"'> "+
					   	"<div class='hot-course-img-one'>"+
					     " <div class='lk'><img src='/read/upload?name="+datas[i].coPhoto+"' style='height: 120px;'/>"+
					       " <p class='hot-black-txt' style='height: 30px;font-size: 20px;padding-top: 10px;'>"+
					      " <span class='fl' style='font-size: 14px;color: red;'>"+(i*1+1)+"</span>"+ 
					       "	<span class='fl' style='margin-left: 20px;'>"+datas[i].coName+"</span>"+
					        "	<span class='fr' style='color: orange;'>￥"+datas[i].salePrice+"</span>"+
					       " </p>"+
					     " </div>"+
					   " </div>"+
				  "  </a>");
			}else{
				$(".hot-course-img-con").append("<div class='hot-course-img-one'>"+
					     " <div class='lk' style='position:relative;'><img src='/read/upload?name="+datas[i].coPhoto+"' style='height: 120px;'/>"+
					       " <p class='hot-black-txt' style='height: 30px;font-size: 20px;padding-top: 10px;'>"+
					      " <span class='fl' style='font-size: 14px;color: red;'>"+(i*1+1)+"</span>"+ 
					       "	<span class='fl' style='margin-left: 20px;'>"+datas[i].coName+"</span>"+
					        "	<span class='fr' style='color: orange;'>￥"+datas[i].salePrice+"</span>"+
					       " </p>"+
					      "<div style='position:absolute;width:100px;height:100px;z-indent:2;left:0;top:0;'>"+
			       			"<img src='/assets/images/timg.png' style='height: 50px;width:50px;'/>"+
			    			"</div>"+
					     " </div>"+
					   " </div>");
			}
			
			
			
			
			
		}
		
	}
